// 查询订单dto
import { DtoValidation } from '@/modules/core/decorators/dto-validation.decorator';
import { Injectable } from '@nestjs/common';
import { IsOptional, IsEnum, Min, IsNumber } from 'class-validator';
import { ORDER_STATUS } from '../contance';
import { Transform } from 'class-transformer';

@Injectable()
@DtoValidation({ type: 'body' })
export class OrderListDto {
  @IsOptional()
  @IsEnum(ORDER_STATUS)
  status: number;

  @Transform((value) => {
    return Number(value.value);
  })
  @IsOptional({
    always: true,
  })
  @Min(1, { message: '值必须大于1' })
  @IsNumber()
  pageNumber = 1;

  @Transform((value) => {
    return Number(value.value);
  })
  @IsOptional({
    always: true,
  })
  @Min(1, { message: '值必须大于1' })
  @IsNumber()
  pageSize = 20;
}
